/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.unmsm.cinfo.siga.datos;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author alumno
 */
@Entity
@Table(name = "CURSO_BASE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CursoBase.findAll", query = "SELECT c FROM CursoBase c"),
    @NamedQuery(name = "CursoBase.findByCurbCod", query = "SELECT c FROM CursoBase c WHERE c.curbCod = :curbCod"),
    @NamedQuery(name = "CursoBase.findByCurbNom", query = "SELECT c FROM CursoBase c WHERE c.curbNom = :curbNom"),
    @NamedQuery(name = "CursoBase.findByCurbEst", query = "SELECT c FROM CursoBase c WHERE c.curbEst = :curbEst")})
public class CursoBase implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @GeneratedValue(generator="cursoCodGen")
    @SequenceGenerator(name="cursoCodGen", sequenceName="CURSO_COD_GEN", allocationSize=1)
    @Column(name = "CURB_COD")
    private Integer curbCod;
    @Column(name = "CURB_NOM")
    private String curbNom;
    @Column(name = "CURB_EST")
    private Short curbEst;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cursoBase", fetch = FetchType.LAZY)
    private List<ModuloCurso> moduloCursoList;
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);

    public CursoBase() {
    }

    public CursoBase(Integer curbCod) {
        this.curbCod = curbCod;
    }

    public Integer getCurbCod() {
        return curbCod;
    }

    public void setCurbCod(Integer curbCod) {
        Integer old = this.curbCod;
        this.curbCod = curbCod;
        changeSupport.firePropertyChange("curbCod", old, curbCod);
    }

    public String getCurbNom() {
        return curbNom;
    }

    public void setCurbNom(String curbNom) {
        String old = this.curbNom;
        this.curbNom = curbNom;
        changeSupport.firePropertyChange("curbNom", old, curbNom);
    }

    public Short getCurbEst() {
        return curbEst;
    }

    public void setCurbEst(Short curbEst) {
        Short old = this.curbEst;
        this.curbEst = curbEst;
        changeSupport.firePropertyChange("curbEst", old, curbEst);
    }

    @XmlTransient
    public List<ModuloCurso> getModuloCursoList() {
        return moduloCursoList;
    }

    public void setModuloCursoList(List<ModuloCurso> moduloCursoList) {
        this.moduloCursoList = moduloCursoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (curbCod != null ? curbCod.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CursoBase)) {
            return false;
        }
        CursoBase other = (CursoBase) object;
        if ((this.curbCod == null && other.curbCod != null) || (this.curbCod != null && !this.curbCod.equals(other.curbCod))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.edu.unmsm.cinfo.siga.datos.CursoBase[ curbCod=" + curbCod + " ]";
    }
    
    public void addPropertyChangeListener(PropertyChangeListener l){
        changeSupport.addPropertyChangeListener(l);
    }
    
    public void removePropertyChangeListener(PropertyChangeListener l){
        changeSupport.removePropertyChangeListener(l);
    }
    
}
